<html>
<head>
    <script type="text/javascript" src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
</head>
<body onload="javascript:pay();">
<script type="text/javascript">
    function pay() {
        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        } else {
            onBridgeReady();
        }
    }

    function onBridgeReady() {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', {
                "appId": "${appid}",     //公众号名称，由商户传入
                "timeStamp": "${timeStamp}",         //时间戳，自1970年以来的秒数
                "nonceStr": "${nonceStr}", //随机串
                "package": "${packageValue}",
                "signType": "MD5",         //微信签名方式:
                "paySign": "${paySign}"    //微信签名
            }, function (res) {
                if (res.err_msg == "get_brand_wcpay_request:ok") {
                    // 支付成功跳转到页面
                    weui.alert('微信支付成功，我们会尽快确认给你发货');

                } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                    weui.alert('您取消了微信支付');

                } else {
                    weui.alert('微信支付失败');

                }
            });
    }
</script>
</body>
</html>